<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang='zh-CN' xml:lang='zh-CN' xmlns='http://www.w3.org/1999/xhtml'>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
        <meta http-equiv="Content-Language" content="zh-CN"/>
        <meta name="robots" content="index, follow" />
        <link rel="shortcut icon" type="image/x-icon" href="img/favicon.ico" />
        <title>氿上网</title>
        <?php echo $this->_var['system_css']; ?>
        <?php echo $this->_var['system_js']; ?>
    </head>
    <body>
        <div id="OSC_Screen">
            <?php echo $this->fetch('header.html'); ?>
            <div id="OSC_Content" class='CenterDiv'>
                <?php echo $this->fetch('user_nav.html'); ?>
                <?php echo $this->fetch('message.html'); ?>
                <div class="MainForm" id="reg_page">
                    <table width="100%" cellspacing="0" style="border:1px solid #ccc;">
                        <thead style="border:1px solid #ccc;">
                            <tr >
                                <th width="20%" style="border:1px solid #ccc;">产品名称</th>
                                <th width="20%" style="border:1px solid #ccc;">产品图片</th>
                                <th style="border:1px solid #ccc;">添加时间</th>
                                <th style="border:1px solid #ccc;">操作</th>
                            </tr>
                        </thead>
                        <tbody style="border:1px solid #ccc;">
                            <?php $_from = $this->_var['goods_list']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }; $this->push_vars('', 'list');if (count($_from)):
    foreach ($_from AS $this->_var['list']):
?>
                            <tr class="goods_div_<?php echo $this->_var['list']['id']; ?>">
                                <td  style="border:1px solid #ccc;" width="30%"><a href="<?php echo $this->_var['list']['goods_url']; ?>" target="_blank"><?php echo $this->_var['list']['name']; ?></a></td>
                                <td style="border:1px solid #ccc;" ><a href="<?php echo $this->_var['list']['goods_url']; ?>" target="_blank"><img src="<?php echo $this->_var['list']['goods_image']; ?>" width="100" height="100"/></a></td>
                                <td style="border:1px solid #ccc;" ><?php echo Date::timeformat($this->_var['list']['add_time'],3); ?></td>
                                <td style="border:1px solid #ccc;" >

                                    <?php if ($this->_var['operate_type'] == 'onsale'): ?>
                                    <a href="javascript:void(0);" class="operate" name="downsale" title="<?php echo $this->_var['list']['name']; ?>" id="<?php echo $this->_var['list']['id']; ?>">下架</a> | 
                                    <?php endif; ?>

                                    <?php if ($this->_var['operate_type'] == 'downsale' || $this->_var['operate_type'] == 'recycle'): ?>
                                    <a href="javascript:void(0);" class="operate" name="onsale" title="<?php echo $this->_var['list']['name']; ?>" id="<?php echo $this->_var['list']['id']; ?>">上架</a> | 
                                    <?php endif; ?>

                                    <?php if ($this->_var['operate_type'] == 'onsale' || $this->_var['operate_type'] == 'downsale'): ?>
                                    <a href="<?php echo $this->_var['site_url']; ?>shop/seller/goods/edit/<?php echo $this->_var['list']['id']; ?>">编辑</a> | 
                                    <?php endif; ?>

                                    <a href="javascript:void(0);" class="delete" title="<?php echo $this->_var['list']['name']; ?>" id="<?php echo $this->_var['list']['id']; ?>">删除</a>

                                    <p class="msg_<?php echo $this->_var['list']['id']; ?>" style="color:red"></p>
                                </td>
                            </tr>  
                            <?php endforeach; endif; unset($_from); ?><?php $this->pop_vars();; ?>
                        </tbody>
                        <tfoot><tr><td colspan="3"><?php echo $this->_var['page']; ?></td></tr></tfoot>
                    </table>

                    <div class='clear'></div>
                </div>

            </div>
            <div class='clear'></div></div>
        <div class='clear'></div>
        <?php echo $this->fetch('footer.html'); ?>
        </div>
        <script type="text/javascript">
            $(function(){
              
                $('.delete').click(function(){
                    var title = $(this).attr('title');
                    var answer = confirm('你确定要删除-'+title+'-吗？');
                    var id = $(this).attr('id');
                    if (answer){
                        $.ajax({
                            url:'/shop/ajax/delete_goods/'+id,
                            type:'POST',
                            data:'id='+id,
                            success:function(data){
                                $(".msg_"+id).show().html(data).fadeOut(2000);
                                if(data == '删除成功' || data=='产品加入回收站'){
                                    $('.goods_div_'+id).remove();
                                }
                            }
                        });
                    }
                });
                
                $('.operate').click(function(){
                    var title = $(this).attr('title');
                    var answer = confirm('你确定要操作-'+title+'-吗？');
                    var act = $(this).attr('name');
                    var id = $(this).attr('id');
                    if (answer){
                        $.ajax({
                            url:'/shop/ajax/operate_goods/'+id,
                            type:'POST',
                            data:'id='+id+'&act='+act,
                            success:function(data){
                                $(".msg_"+id).show().html(data).fadeOut(2000);
                                if(data == '操作成功'){
                                    $('.goods_div_'+id).remove();
                                }
                            }
                        });
                    }
                });
            });
            
        </script>
    </body>
</html>
